layui.config({
    base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
    var form = layui.form(),
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        $ = layui.jquery;

    form.on("submit(admRole)",function(data){
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
         var areaArr = new Array();
        $('input[name=area]:checked').each(function () {
            areaArr.push($(this).val());
        })


        $.ajax({
            type:'post',
            url:'/admin/role/adm',
            async:false,
            data:{
                '_token':$('input[name=_token]').val(),
                'roleId':$('input[name=roleId]').val(),
                "areaArr":areaArr
            },
            dataType:'json',
            success:function (data) {
                if(data.status == 1){   
                      top.layer.close(index);
                      top.layer.msg("提交成功！");
                    layer.closeAll("iframe");
                    //刷新父页面
                    // parent.location.reload();
                }
            }
        })
        return false;

    })
})
